﻿
$(function () {
    loadData();
});

function loadData() {
    $.ajax({
        type: "GET",
        url: "/XSXXInfo/GetAllIsDisplay",
        success: function (data) {
            load_gzdxItem(data, 1);
            load_tjdxItem(data, 2);
            load_zsdxItem(data, 3);
        }
    });
}

//datas[i].pics.split("|")[1]   表示pics字段用"|"分隔成数组，取第一个
function load_gzdxItem(datas, caseTypeId) {
    $("#gzdxItem").html("");    
    for (var i = 0; i < datas.length; i++) {
        if (datas[i].xsxxTypeId === caseTypeId) {
            var tr = "<a class='item-box' href='/XSXXInfo/Detail?id=" + datas[i].id + "'>" +
                                    "<div class='item-border'>" +
                                    "<div class='item-img-box'>" +
                                    "<img class='item-img' src='/UploadFiles/" +
                                    datas[i].pics.split("|")[1]
                                    + "'>" +
                                    "<div class='item-title'>" + datas[i].title + "</div>" +
                                    "</div></div></a>";
            $("#gzdxItem").append(tr);
        }
    }
};

function load_tjdxItem(datas, caseTypeId) {
    $("#tjdxItem").html("");
    for (var i = 0; i < datas.length; i++) {
        if (datas[i].xsxxTypeId === caseTypeId){
            var tr = "<a class='item-box' href='/XSXXInfo/Detail?id=" + datas[i].id + "'>" +
                                    "<div class='item-border'>" +
                                    "<div class='item-img-box'>" +
                                    "<img class='item-img' src='/UploadFiles/" + datas[i].pics.split("|")[1] + "'>" +
                                    "<div class='item-title'>" + datas[i].title + "</div>" +
                                    "</div></div></a>";
            $("#tjdxItem").append(tr);
        }
    }
};

function load_zsdxItem(datas, caseTypeId) {
    $("#zsdxItem").html("");
    for (var i = 0; i < datas.length; i++) {
        if (datas[i].xsxxTypeId === caseTypeId){
            var tr = "<a class='item-box' href='/XSXXInfo/Detail?id=" + datas[i].id + "'>" +
                                    "<div class='item-border'>" +
                                    "<div class='item-img-box'>" +
                                    "<img class='item-img' src='/UploadFiles/" + datas[i].pics.split("|")[1] + "'>" +
                                    "<div class='item-title'>" + datas[i].title + "</div>" +
                                    "</div></div></a>";
            $("#zsdxItem").append(tr);
        }
    }
};